{% extends 'IcsocUIBundle::page.html.twig' %}
{% form_theme form 'IcsocUIBundle:Form:fields.html.twig' %}
{% from 'IcsocUIBundle:Macro:formValidator.html.twig' import jqvalidator %}
{% from 'IcsocUIBundle:Macro:actions.html.twig' import create %}
{% block stylesheet %}
    {{ parent() }}
    {% stylesheets
    '@jqgird_css'
    filter='cssrewrite' filter='uglifycss'
    %}
    <link rel="stylesheet" href="{{ asset_url }}" />
    {% endstylesheets %}
{% endblock %}

{% block content %}
    <div class="page-content">
            {{ form_start(form,{'attr':{'id':'menu_form'}}) }}
                {{ form_widget(form) }}
                {{ create(path('icsoc_menu_homepage')) }}
            {{ form_end(form) }}
    </div>
{% endblock %}
{% block footer %}
    {% javascripts
    '@jqvalidate_js'
    '@common_js'
    filter='uglifyjs'
    %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
    <script>
        var validator = $('#menu_form').validate({
            {{ jqvalidator() }}
            rules: {
                'menu[menuText]': {
                    required: true,
                    remote: {
                        url: '{{ path('icsoc_menu_menu_check') }}',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            name: function(){
                                return $('#menu_menuText').val();
                            },
                            parentId: function(){
                                return $('#menu_parentId').val();
                            },
                            id: "{{ id }}"
                        }
                    }
                },
                'menu[menuIcon]': {required:false}
            },
            messages: {
                'menu[menuText]': {required:"{{ 'Menu name cannot be empty'|trans }}", remote: "{{ 'Menu already exists'|trans }}"}
            }
        });
        $(document).ready(function(){
            $('#menu_file').ace_file_input({
                no_file:'{{ 'No File'|trans }} ...',
                btn_choose:'{{ 'Choose'|trans }}',
                btn_change:'{{ 'Re selection'|trans }}',
                onchange:null,
                thumbnail:false
            });
        })
    </script>

{% endblock %}
